<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page import="model.News" %>
<%@ page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>新闻浏览</title>
    <link rel="stylesheet" type="text/css" href="../layui-v2.9.10/layui/css/layui.css"/>
    <!-- 自定义样式 -->
    <style>
        body {
            background-color: #f5f5f5;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            padding: 0;
        }
        .layui-nav-child{
            color: #0C0C0C;
        }
        .layui-header {
            background-color: #303030;
            color: #fff;
            padding: 0 15px;
        }
        .layui-header .layui-logo {
            font-size: 24px;
            line-height: 60px;
            margin-right: 30px;
        }

        .layui-side, .layui-layout-admin .layui-body, .layui-footer {
            background-color: #f5f5f5;
            color: #333;
        }
        .layui-card-header {
            background-color: #303030;
            color: #fff;
        }
        .layui-card-body {
            background-color: #fff;
            color: #333;
        }
        .layui-layout-admin .layui-body {
            padding: 15px;
        }
        .layui-side {
            background-color: #333; /* 背景颜色 */
            flex-shrink: 0;
        }
        .layui-side-scroll {
            height: 100%; /* 高度设为100% */
            overflow: auto;
        }
        table {
            border-collapse: collapse;
            width: 100%;
        }
        th, td {
            border: 1px solid #dddddd;
            text-align: left;
            padding: 8px;
        }
        th {
            background-color: #f2f2f2;
        }
        form {
            margin-top: 20px;
        }
        form input[type="text"], form input[type="file"] {
            width: 100%;
            margin-bottom: 10px;
            padding: 8px;
        }
        form input[type="submit"] {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            cursor: pointer;
        }
    </style>
</head>
<body>
<div class="layui-layout layui-layout-admin">

    <%-- 头部导航 --%>

        <div class="layui-header">
            <a href="home.jsp" >
                <div class="layui-logo layui-hide-xs">新闻发布系统</div>
            </a>

            <!-- 头部区域 -->
            <ul class="layui-nav layui-layout-left">
                <!-- 移动端显示 -->
                <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                    <i class="layui-icon layui-icon-spread-left"></i>
                </li>

            </ul>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
                    <a href="home.jsp">
                        <img src="../image/back-image.jpg" class="layui-nav-img"> <!-- 修改为实际用户头像链接 -->
                        <%= session.getAttribute("username") %>
                    </a>
                    <dl class="layui-nav-child" style="color: #0C0C0C">
                        <dd><a href="home.jsp">首页</a></dd>
                        <dd><a href="info.jsp">个人信息</a></dd>
                        <dd><a href="setting.jsp">设置</a></dd>
                        <dd><a href="../home/login.jsp;">退出</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                    <a>
                        <i class="layui-icon layui-icon-more-vertical"></i>
                    </a>
                </li>
            </ul>
        </div>

        <div class="layui-side">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域 -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <li class="layui-nav-item layui-nav-itemed">
                        <a >个人信息</a>
                        <dl class="layui-nav-child">
                            <dd><a href="info.jsp">查看信息</a></dd>
                            <dd><a href="setting.jsp">修改密码</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item layui-nav-itemed">
                        <a>新闻发布信息</a>
                        <dl class="layui-nav-child">
                            <dd><a href="NewsPublish.jsp">发布新闻</a></dd>
                            <dd><a href="NewsServlet.do">查看新闻</a></dd>
                        </dl>
                    </li>

                </ul>
            </div>
        </div>

    <%-- 主体内容 --%>
        <div class="layui-body">
            <h2>新闻列表</h2>
            <table>
                <thead>
                <tr>
                    <th>标题</th>
                    <th>作者</th>
                    <th>内容</th>
                    <th>图片</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="news" items="${sessionScope.newsList}">
                    <tr>
                        <td>${news.title}</td>
                        <td>${news.author}</td>
                        <td>${news.content}</td>
                        <td><img src="${pageContext.request.contextPath}/${news.imagePath}" style="text-align: center" width="80px" height="80px" alt="新闻图片"></td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>

    <div class="layui-footer">
        © 新闻发布系统 - 版权所有
    </div>

</div>
</body>
</html>
